//
// Created by wangyz38535 on 2021/9/27.
//

#ifndef OPTIMIZED_CPLUSPLUS_VECTOR_LIST_H
#define OPTIMIZED_CPLUSPLUS_VECTOR_LIST_H
#include <iostream>
#include <ostream>
#include <vector>
#include <iterator>
#include "linear_list.h"

using namespace std;

template <typename T>
class VectorList : public LinearList<T>
{
public:
    // constructor, copy constructor and destructor
    explicit VectorList(int initialCapacity = 10);
    VectorList(const VectorList<T> &);
    ~VectorList() { delete m_element; }

    // ADT methods
    bool Empty() const { return m_element->empty(); }
    int Size() const { return (int)m_element->size(); }
    T &Get(int theIndex) const;
    int IndexOf(const T &theElement) const;
    void Erase(int theIndex);
    void Insert(int theIndex, const T &theElement);
    void Output(ostream &out) const;

    // additional method
    int Capacity() const { return (int)m_element->capacity(); }

    // iterators to start and end of list
    typedef typename vector<T>::iterator iterator;
    iterator Begin() { return m_element->begin(); }
    iterator End() { return m_element->end(); }

protected: // additional members of vectorList
    void CheckIndex(int theIndex) const;
    vector<T> *m_element; // vector to hold list elements
};



#endif //OPTIMIZED_CPLUSPLUS_VECTOR_LIST_H
